]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
location: Add dialog to ask for location data access
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 15 Feb 2016 19:42:09 +0000 (19:42 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 18 Feb 2016 15:11:10 +0000 (15:11 +0000)
Add a dialog that is used in a following patch, to ask user if they want
a requesting application to gain access to their location.

Co-author: Florian Müllner <fmuellner@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=762119

data/theme/gnome-shell-high-contrast.css
data/theme/gnome-shell.css
js/ui/status/location.js

index 140785d48929848166957e58edc60198b0a30135..a42016be9576884002aa075ddaace8cdcdccfe9d 100644 (file)
@@ -427,6 +427,22 @@ StScrollBar {
 .audio-selection-device-icon {
   icon-size: 64px; }
 
+/* Geolocation Dialog */
+.geolocation-dialog {
+  spacing: 30px; }
+
+.geolocation-dialog-main-layout {
+  spacing: 12px; }
+
+.geolocation-dialog-content {
+  spacing: 20px; }
+
+.geolocation-dialog-icon {
+  icon-size: 48px; }
+
+.geolocation-dialog-title {
+  font-weight: bold; }
+
 /* Network Agent Dialog */
 .network-dialog-secret-table {
   spacing-rows: 15px;
index 92529a6f351690d2609662cd31194d6a6044bf29..3160a7457dcf1bc1c8db22e877aed0393a06ab25 100644 (file)
@@ -427,6 +427,22 @@ StScrollBar {
 .audio-selection-device-icon {
   icon-size: 64px; }
 
+/* Geolocation Dialog */
+.geolocation-dialog {
+  spacing: 30px; }
+
+.geolocation-dialog-main-layout {
+  spacing: 12px; }
+
+.geolocation-dialog-content {
+  spacing: 20px; }
+
+.geolocation-dialog-icon {
+  icon-size: 48px; }
+
+.geolocation-dialog-title {
+  font-weight: bold; }
+
 /* Network Agent Dialog */
 .network-dialog-secret-table {
   spacing-rows: 15px;
index b106fedef22f2cac7bac6620d07ad34d5dce3729..2dad0b836b8656442939900df9d6f5ba8ab43d1a 100644 (file)
@@ -1,5 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
+const Clutter = imports.gi.Clutter;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
@@ -7,7 +8,10 @@ const Lang = imports.lang;
 const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
+const ModalDialog = imports.ui.modalDialog;
 const Shell = imports.gi.Shell;
+const Signals = imports.signals;
+const St = imports.gi.St;
 
 const LOCATION_SCHEMA = 'org.gnome.system.location';
 const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
@@ -217,3 +221,60 @@ const Indicator = new Lang.Class({
 function clamp(value, min, max) {
     return Math.max(min, Math.min(max, value));
 }
+
+const GeolocationDialog = new Lang.Class({
+    Name: 'GeolocationDialog',
+    Extends: ModalDialog.ModalDialog,
+
+    _init: function(name, reason, reqAccuracyLevel) {
+        this.parent({ styleClass: 'geolocation-dialog' });
+        this.reqAccuracyLevel = reqAccuracyLevel;
+
+        let mainContentBox = new St.BoxLayout({ style_class: 'geolocation-dialog-main-layout' });
+        this.contentLayout.add_actor(mainContentBox);
+
+        let icon = new St.Icon({ style_class: 'geolocation-dialog-icon',
+                                 icon_name: 'find-location-symbolic',
+                                 y_align: Clutter.ActorAlign.START });
+        mainContentBox.add_actor(icon);
+
+        let messageBox = new St.BoxLayout({ style_class: 'geolocation-dialog-content',
+                                            vertical: true });
+        mainContentBox.add_actor(messageBox);
+
+        this._title = new St.Label({ style_class: 'geolocation-dialog-title headline' });
+        messageBox.add_actor(this._title);
+
+        this._desc = new St.Label();
+        messageBox.add_actor(this._desc);
+
+        this._reason = new St.Label();
+        messageBox.add_actor(this._reason);
+
+        let button = this.addButton({ label: _("Deny Access"),
+                                      action: Lang.bind(this, this._onDenyClicked),
+                                      key: Clutter.KEY_Escape });
+        this.addButton({ label: _("Grant Access"),
+                         action: Lang.bind(this, this._onGrantClicked) });
+
+        this.setInitialKeyFocus(button);
+
+        this._title.text = _("Give %s access to your location?").format(name);
+        this._desc.text = _("%s is requesting access to your location.").format(name);
+
+        if (reason)
+            this._reason.text = reason;
+        this._reason.visible = (reason != null);
+    },
+
+    _onGrantClicked: function() {
+        this.emit('response', this.reqAccuracyLevel);
+        this.close();
+    },
+
+    _onDenyClicked: function() {
+        this.emit('response', GeoclueAccuracyLevel.NONE);
+        this.close();
+    }
+});
+Signals.addSignalMethods(GeolocationDialog.prototype);